package com.lam.fundamental;

import java.util.ArrayList;

import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
  
public class FundamentalFragment extends Fragment implements OnClickListener{  
	
	OnFundamentalButtonClickListener mCallback;
	
	public interface OnFundamentalButtonClickListener{
		public void OnFundamentalButtonClick(int viewId);
	}
  
    @Override  
    public View onCreateView(LayoutInflater inflater, ViewGroup container,  
            Bundle savedInstanceState)  {  
    	
    	View view=inflater.inflate(R.layout.fragment_fundamental, container, false);
    	setButtonListener(view);
        return  view;
    }
    
    
    
	@Override
	public void onAttach(Activity activity) {
		// TODO Auto-generated method stub
		super.onAttach(activity);
		 try {
	            mCallback = (OnFundamentalButtonClickListener) activity;
	        } catch (ClassCastException e) {
	            throw new ClassCastException(activity.toString()
	                    + " must implement OnHeadlineSelectedListener");
	        }
	}



	private void setButtonListener(View view) {
	// TODO Auto-generated method stub
	ArrayList<Button> buttons=new ArrayList<Button>();
	buttons.add((Button)view.findViewById(R.id.spinner_button));
	buttons.add((Button)view.findViewById(R.id.bt_checkBox_radio));
	buttons.add((Button)view.findViewById(R.id.bt_tvcolor));
	buttons.add((Button)view.findViewById(R.id.bt_radioSelectDeal));
	buttons.add((Button)view.findViewById(R.id.bt_checkList));
	buttons.add((Button)view.findViewById(R.id.bt_photoframe));
	buttons.add((Button)view.findViewById(R.id.bt_sharedPref));
	buttons.add((Button)view.findViewById(R.id.bt_sqlite));
	buttons.add((Button)view.findViewById(R.id.bt_addContract));
	buttons.add((Button)view.findViewById(R.id.bt_dairy));
	buttons.add((Button)view.findViewById(R.id.bt_sdcardinfo));
	buttons.add((Button)view.findViewById(R.id.bt_web));
	buttons.add((Button)view.findViewById(R.id.bt_showPicInfo));
	buttons.add((Button)view.findViewById(R.id.bt_Animation));
	buttons.add((Button)view.findViewById(R.id.bt_httpclient));
	buttons.add((Button)view.findViewById(R.id.bt_listview));
	for (int i = 0; i < buttons.size(); i++) {
		if(buttons.get(i)!=null){
			buttons.get(i).setOnClickListener(this);
		}
	}
}

@Override
public void onClick(View v) {
	mCallback.OnFundamentalButtonClick(v.getId());
}

  
}  